// ==========================================================================
// GFast自动生成controller操作代码。
// 生成日期：2023-11-08 10:11:31
// 生成路径: internal/app/plugin/mail/controller/plugin_mail.go
// 生成人：gfast
// desc:邮件发送
// company:云南奇讯科技有限公司
// ==========================================================================

package controller

import (
	"context"

	"github.com/tiger1103/gfast/v3/api/v1/plugins/mail"
	"github.com/tiger1103/gfast/v3/internal/app/plugins/mail/service"
	systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller"
)

type mailController struct {
	systemController.BaseController
}

var PluginMail = new(mailController)

// List 列表
func (c *mailController) List(ctx context.Context, req *mail.PluginMailSearchReq) (res *mail.PluginMailSearchRes, err error) {
	res = new(mail.PluginMailSearchRes)
	res.PluginMailSearchRes, err = service.PluginMail().List(ctx, &req.PluginMailSearchReq)
	return
}

// Get 获取邮件发送
func (c *mailController) Get(ctx context.Context, req *mail.PluginMailGetReq) (res *mail.PluginMailGetRes, err error) {
	res = new(mail.PluginMailGetRes)
	res.PluginMailInfoRes, err = service.PluginMail().GetById(ctx, req.Id)
	return
}

// Add 添加邮件发送
func (c *mailController) Add(ctx context.Context, req *mail.PluginMailAddReq) (res *mail.PluginMailAddRes, err error) {
	err = service.PluginMail().Add(ctx, req.PluginMailAddReq)
	return
}

// Edit 修改邮件发送
func (c *mailController) Edit(ctx context.Context, req *mail.PluginMailEditReq) (res *mail.PluginMailEditRes, err error) {
	err = service.PluginMail().Edit(ctx, req.PluginMailEditReq)
	return
}

// Delete 删除邮件发送
func (c *mailController) Delete(ctx context.Context, req *mail.PluginMailDeleteReq) (res *mail.PluginMailDeleteRes, err error) {
	err = service.PluginMail().Delete(ctx, req.Ids)
	return
}
func (c *mailController) SendData(ctx context.Context, req *mail.PluginMailSendDataReq) (res *mail.PluginMailSendDataRes, err error) {
	err = service.PluginMail().SendData(ctx, req.MailReq)
	return
}
